<?php
/**
*
* 功能描述（蛋糕评价控制器）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*/

class CtrlComment extends CtrlBase
{
	public $paramCheck = array(
		'showlist' => array(
			'size' => array('GET', '0', 'intval', 'notnegative', 's'),
			'visible' => array('GET', '2', 'intval', 'notnegative', 's'),
			'whole' => array('GET', '9', 'intval', 'notnegative', 's'),
			'taste' => array('GET', '9', 'intval', 'notnegative', 's'),
			'service' => array('GET', '9', 'intval', 'notnegative', 's'),
			'c_start' => array('GET', '', '', 'datetime', 's'),
			'c_end' => array('GET', '', '', 'datetime', 's'),
			'key' => array('GET', '', 'trim', '', 's'),
			'keyword' => array('GET', '', 'trim', '', 's'),
			'page' => array('GET', '1', 'intval', 'positive'),
			'pageSize' => array('GET', 30, 'intval', 'positive'),
		),
		"setvisible" => array(
			'id' => array("GET", "must", "intval", "positive"),
			'visible' => array("GET", "must", "intval", "bool"),
		),
	);

	public $perm = array('cake', "index.php?action=login.tologin");

	function ShowList()
	{
		$obj = $this->GetModel("comment");
		$data = $obj->GetList($this->search, $this->page);
		$this->assign("listdata", $data);
		return RT_TPL;
	}

	function SetVisible()
	{
		$obj = $this->GetModel("comment");
		$id = $this->params['id'];
		$vis = $this->params['visible'];
		$data = array(
			'visible' => $vis,
		);
		$cnt = $obj->Update($id, $data);
		if($cnt == 0)
			echo "2";
		else
		{
			echo "0";
			$this->CoreLog('comment_visible', $id, $vis, '');
		}
		return RT_NONE;
	}
}

